<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="EventUtil.js"></script>
    <script src="Script.js"></script>
    <title>兼容性DOM0,DOM2事件</title>

</head>
<body>
<div id="box">
    <input id="btn1" type="button" onclick="showMessage()" value="按钮1"/>
    <input id="btn2" type="button" value="按钮2"/>
    <input id="btn3" type="button" value="按钮3"/>
</div>

<script>
    function showMessage() {
        alert("HelloWorld");
    }

    //DOM2添加事件
    var ele2 = document.getElementById("btn2");
    //    ele2.addEventListener("click",showMessage,false);
    var ele3=document.getElementById("btn3");
    //DOM0添加事件
    //    ele3.onclick=function(){
    //        alert("通过DOM0添加Onclick事件");
    //    }

    eventUtil.addHandler(ele2,"click",showMessage);

    eventUtil.addHandler(ele3,"click",showMessage);
</script>
</body>

</html>